package com.cloudptt.wp.ui.more;
//Download by htp://www.codefans.net


import android.app.Activity;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.cloudptt.api.comm.CommInfo;
import com.cloudptt.api.models.VersionInfo;
import com.cloudptt.wp.R;
import com.cloudptt.wp.ScreenManager;

public class VersionInfoActivity extends Activity implements OnClickListener {
	
	private TextView returnBtn; 
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		Window window = getWindow();
		window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
		//window.setStatusBarColor(getResources().getColor(R.color.app_theme_color_primary));
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_version);
		
		getActionBar().setBackgroundDrawable(getResources().getDrawable(R.color.app_theme_color_primary));
		getActionBar().hide();
		
		TextView versionText = (TextView)findViewById(R.id.versionText);
		versionText.setText(getVersion());

		TextView tv = (TextView) findViewById(R.id.titleTv);
		tv.setText(R.string.about_us);

		ScreenManager.getScreenManager().pushActivity(this);
	}
	
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// TODO Auto-generated method stub
		
		if(android.R.id.home == item.getItemId()){
			finish();
			return true;
		}
		
		return super.onOptionsItemSelected(item);
	}
	
	public void onClick(View v) {
		int id = v.getId();
//		if(id == R.id.back_up_icon)
//		{
//			this.finish();
//		}
	}

	/**
	 * 锟斤拷取锟芥本锟斤拷
	 * @return 锟斤拷前应锟矫的版本锟斤拷
	 */
	public String getVersion() {
	    try {
	    	VersionInfo verInfo = CommInfo.getVersionInfo(VersionInfoActivity.this);
	        String version = verInfo.getName() + "(" + verInfo.getVersionCode() + ")";
	        return getString(R.string.current_version) + version;
	    } catch (Exception e) {
	        e.printStackTrace();
	        return "";
	    }
	}

	public void login_back(View v) {     
		this.finish();
	}  
	
}
